{extend name="common/application" /}
{block name="title"}<title>政务资讯-详情</title>{/block}
{block name="css"}

<link rel="stylesheet" type="text/css" href="_CSS_/government.css"/>
<link rel="stylesheet" href="_CSS_/government_details.css"/>
<!--[if lt IE 9]>
<script src="http://www.ijquery.cn/js/html5shiv.js"></script>
<![endif]-->
<style type="text/css">
    .detailsBody img{max-width: 707px;}
	.praiseBtn {margin: 65px 107px 65px 180px;}
	.praiseNum{width:20px;display:inline-block;text-align:center;}
	.detailsBody{min-height:500px;}
</style>
{/block}
{block name="navbar"}{include file="/common/navbar" /}{/block}
{block name="content"}
<!-- 主体内容 -->
<div class="main">
    <div class="mainBody normalBox clearfix">
        <div class="leftCon fl">
            <!--面包屑导航-->
            <div class="breadcrumb">
                <p>当前位置：
                    <a href="index.html">政务资讯</a> &gt;
                    <a></a> &gt;
                    <a class="curPage" href="javascript:;">正文</a>
                </p>
            </div>
            <!--国务院要闻-->
            <div class="importantNews sectionArea" style="margin-top: 0;">
                <div class="conBody textsDetails">
                    <div class="detailsHeader">
                        <h4></h4>
                        <div class="sectionTags fl">
                            <p class="time"><span class="icons icon-time"></span></p>
                            <p class="view"><span class="icons icon-view"></span></p>
                            <p class="praise"><span class="icons icon-praise"></span></p>
                            <p class="collect"><span class="icons icon-collect"></span></p>
                        </div>
                    </div>
                    <div class="detailsBody">
                    </div>
                    <div class="detailsFooter">
						<!--分享按钮-->                         
						<div class="bshare-custom fl" style="margin-top: 95px;">
							<a title="分享到新浪微博" class="bshare-sinaminiblog"></a>
							<a title="分享到QQ空间" class="bshare-qzone"></a>
							<a title="分享到微信" class="bshare-weixin"></a>
							<a title="分享到QQ好友" class="bshare-qqim"></a>
							<a title="更多平台" class="bshare-more bshare-more-icon more-style-addthis"></a>
							<span class="BSHARE_COUNT bshare-share-count">0</span>
						</div>
						<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/button.js#style=-1&amp;uuid=&amp;pophcol=2&amp;lang=zh"></script>
						<a class="bshareDiv" onclick="javascript:return false;"></a>
						<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/bshareC0.js"></script>
					
                        <div class="shareArea fl hide">
                            <div class="shareBtn" style="position: relative;">
                                <span class="icons icon-share"></span>
                                <span class="icons icon-active-share hide"></span>
                            </div>
                            <p>快给朋友分享吧</p>
                        </div>
                        <div class="praiseArea fl">
                            <div class="praiseBtn">
                                <span class="icons icon-grey-praise"></span>
                                <span class="icons icon-active-praise hide"></span>
                                <span class="icons icon-success-praise hide"></span>
                                <span class="praiseNum"></span>
                            </div>
                        </div>
                        <div class="collectArea fr">
                            <div class="collectBtn">
                                <span class="icons icon-star"></span>
                                <span class="icons icon-active-star hide"></span>
                                <span class="icons icon-success-star hide"></span>
                            </div>
                            <p><span class="collcetNum"></span>人已收藏</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="rightCon fr">
            <!--政策信息-->
            <div class="policyInfo">
                <h4 class="conHeader">
                    <p class="sectionName fl">
                        <span class="icons icon-hot"></span>
                        <span>热门政务</span>
                    </p>
                    <!--<a class="readMore fr" href="javascript:;">更多<span class="icons icon-right"></span></a>-->
                </h4>
                <div class="conBody">
                    <ul class="infoList">

                    </ul>
                </div>
            </div>
            <!--政策信息-->
            <div class="commend">
                <h4 class="conHeader">
                    <p class="sectionName fl">
                        <span class="icons icon-like"></span>
                        <span>猜你喜欢</span>
                    </p>
                    <!--<a class="readMore fr" href="javascript:;">更多<span class="icons icon-right"></span></a>-->
                </h4>
                <div class="conBody">
                    <ul class="infoList">

                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}


{block name="js"}
<!-- 脚本引入 -->

<script type="text/javascript" src="_P_/layer/layer.js"></script>
<script src="_JS_/qrcode.js"></script>
<script type="text/javascript" src="_JS_/getDate.js"></script>
<script src="_JS_/government_details.js"></script>
<script type="text/javascript">
    var url = window.location.href;
    isPraise = false;
    isShare = false;
    isCollect = false;
    praise = 0;
    collect = 0;
    id = url.split("=")[1];
    var r = /^\+?[1-9][0-9]*$/;　　//正整数
    var userinfo = $.cookie('userinfo');
    if (userinfo) {
        var loginStatus = $.base64.decode(userinfo).split(",");
        var uid = loginStatus[0];
        $.ajax({
            type: "get",
            url: "/index.php/api/news/user_information",
            data: {'id': uid,'type':3},
            dataType: 'jsonp',
            success: function (msg) {
                if (msg.code == 200) {
                    if (msg.data.indexOf(parseInt(id)) !== -1) {
                        $('.icon-star').addClass('hide');
                        $('.icon-active-star').addClass('hide');
                        $('.icon-success-star').removeClass('hide');
                        isCollect = true;
                        collect = 1;
                    } else {
                        $('.icon-star').removeClass('hide');
                        $('.icon-active-star').addClass('hide');
                        $('.icon-success-star').addClass('hide');
                        isCollect = false;
                        collect = 0;
                    }

                }
            }
        });
		$.ajax({
            type:"get",
            url:"/index.php/api/video/user_likes",
            data:{'uid':uid,'type':2,'id':id},
            dataType:'jsonp',
            success:function(msg){
                if(msg.code == 200){
                    $('.icon-grey-praise').addClass('hide');
                    $('.icon-active-praise').addClass('hide');
                    $('.icon-success-praise').removeClass('hide');
                    isPraise = true;
                    praise = 1;
                }else{
                    $('.icon-grey-praise').removeClass('hide');
                    $('.icon-active-praise').addClass('hide');
                    $('.icon-success-praise').addClass('hide');
                    isPraise = false;
                    praise = 0;
                }
            }
        })
    }

    $(function () {
        $.ajax({
            type: "get",
            url: "/index.php/api/news/government_detail",
            data: {'id': id},
            dataType: 'jsonp',
            success: function (msg) {
                if (msg.code == 200) {
                    
                    var time = msg.data.time;
                    ltime = getMyDate(time * 1000);
                    $('.detailsHeader').find('h4').html(msg.data.title);
                    $('.sectionTags').find("span:eq(0)").after(ltime);
                    $('.sectionTags').find("span:eq(1)").after(msg.data.views);
                    $('.sectionTags').find("span:eq(2)").after(msg.data.likes);
                    $('.sectionTags').find("span:eq(3)").after(msg.data.collect);
                    $('.detailsBody').html(msg.data.content);
                    $('.praiseNum').html(msg.data.likes);
                    $('.collcetNum').html(msg.data.collect);
                    $('.breadcrumb').find("a:eq(1)").html(msg.data.name);
                    $('.breadcrumb').find("a:eq(1)").attr("href", "government_list.html#" + msg.data.type);
                }
                if (msg.code == 1000) {
                    layer.msg('查询失败!', {icon: 1, time: 1000});
                }
            }
        });
        $.ajax({
            type: "get",
            url: "/index.php/api/news/views",
            data: {'id': id, 'sheet': 'government_work'},
            dataType: 'jsonp',
            success: function (msg) {
                if (msg.code == 200) {
                }
            }
        });
        hot_view();
        guess_like();
    });

    //热门政务
    function hot_view() {
        $.ajax({
            type: "get",
            url: "/index.php/api/news/government_list",
            data: {'number': 5, 'sheet': 'government_work', 'status': 1},
            dataType: 'jsonp',
            success: function (msg) {
                var html = "";
                $(".infoList").eq(0).html('');
                if (msg.code == 200) {
                    for (var i = 0; i < msg.data.data.length; i++) {
                        var time = msg.data.data[i].time;
                        ltime = getMyDate(time * 1000);
                        var src = msg.data.data[i].pic ;
						var title = msg.data.data[i].title;
						if(title.length>13){
							title01 = title.substring(0,13)+'...';
						}else{
							title01 = title; 
						}
                        html += '<li><a class="policyItem" href="government_details.html?id=' + msg.data.data[i].id + '">';
                        html += '<img class="fl" src="' + src + '"/>';
                        html += '<span class="moreline fr" limit="13" title="'+ title +'">' + title01 + '</span>';
                        html += '<p class="fr time"><span class="icons icon-time"></span>' + ltime + '</p></a></li>';
                    }
                    $(".infoList").eq(0).html(html);
                }
            }
        });
    }

    //猜你喜欢
    function guess_like() {
        $.ajax({
            type: "get",
            url: "/index.php/api/news/government_list",
            data: {'number': 5, 'sheet': 'government_work', 'status': 1, 'order': 'rand()'},
            dataType: 'jsonp',
            success: function (msg) {
                var html = "";
                $(".infoList").eq(1).html('');
                if (msg.code == 200) {
                    for (var i = 0; i < msg.data.data.length; i++) {
                        var time = msg.data.data[i].time;
                        ltime = getMyDate(time * 1000);
                        var src = msg.data.data[i].pic ;
						var title = msg.data.data[i].title;
						if(title.length>13){
							var title01 = title.substring(0,13)+'...';
						}else{
							var title01 = title;
						}
                        html += '<li><a class="policyItem" href="government_details.html?id=' + msg.data.data[i].id + '">';
                        html += '<img class="fl" src="' + src + '"/>';
                        html += '<span class="moreline fr" limit="13" title="'+ title +'">' + title01 + '</span>';
                        html += '<p class="fr time"><span class="icons icon-time"></span>' + ltime + '</p></a></li>';
                    }
                    $(".infoList").eq(1).html(html);
                }
            }
        });
    }


    $('.collectBtn').on('click', function () {
        if (r.test(uid)) {
            $.ajax({
                type: "get",
                url: "/index.php/api/news/collect",
                data: {'id': id,  'uid': uid},
                dataType: 'jsonp',
                success: function (msg) {
                    var num = $('.collcetNum').text();
                    if (msg.code == 201) {
                        $('.icon-star').addClass('hide');
                        $('.icon-active-star').addClass('hide');
                        $('.icon-success-star').removeClass('hide');
                        var i = Number(num);
                        i += 1;
                        $('.collcetNum').text(i);
                        isCollect = true;
                        collect = 1;
                        $('.sectionTags').find("p:eq(3)").html('<span class="icons icon-collect"></span>' + i);
                        layer.msg(msg.message, {icon: 1});
                    }
                    if (msg.code == 200) {
                        $('.icon-star').removeClass('hide');
                        $('.icon-active-star').addClass('hide');
                        $('.icon-success-star').addClass('hide');
                        var j = Number(num);
                        j -= 1;
                        $('.collcetNum').text(j);
                        isCollect = false;
                        collect = 0;
                        $('.sectionTags').find("p:eq(3)").html('<span class="icons icon-collect"></span>' + j);
                        layer.msg(msg.message, {icon: 1});
                    }
                    if (msg.code == 1000) {
                        layer.msg(msg.message, {icon: 5});
                    }
                }
            });
        } else {
            layer.msg("请登录", {icon: 5});
        }
    });
    /*收藏按钮悬浮*/
    $('.collectBtn').hover(function () {
        $('.icon-star').addClass('hide');
        if (collect == 0) {
            $('.icon-active-star').removeClass('hide');
        } else {
            $('.icon-success-star').removeClass('hide');
        }
    }, function () {
        if (!isCollect) {
            if (collect == 0) {
                $('.icon-star').removeClass('hide');
            } else {
                $('.icon-success-star').removeClass('hide');
            }
            $('.icon-active-star').addClass('hide');
        }
    });
    /*点赞*/
    $('.praiseBtn').on('click', function () {
        if (r.test(uid)) {
            $.ajax({
                type: "get",
                url: "/index.php/api/news/likes",
                data: {'id': id, 'uid': uid, 'sheet': 'government_work'},
                dataType: 'jsonp',
                success: function (msg) {
                    var num = $('.praiseNum').text();
                    if (msg.code == 200) {
                        $('.icon-grey-praise').addClass('hide');
                        $('.icon-active-praise').addClass('hide');
                        $('.icon-success-praise').removeClass('hide');
                        isPraise = true;
                        praise = 1;
                        var i = Number(num);
                        i += 1;
                        $('.praiseNum').text(i);
                        layer.msg(msg.message, {icon: 1});
                    }
                    if (msg.code == 201) {
                        $('.icon-grey-praise').removeClass('hide');
                        $('.icon-active-praise').addClass('hide');
                        $('.icon-success-praise').addClass('hide');
                        isPraise = false;
                        praise = 0;
                        var j = Number(num);
                        j -= 1;
                        $('.praiseNum').text(j);
                        layer.msg(msg.message, {icon: 1});
                    }
                    if (msg.code == 1000) {
                        layer.msg(msg.message, {icon: 5});
                    }
                }
            });
        } else {
            layer.msg("请登录", {icon: 5});
        }
    });
    /*点赞按钮悬浮*/
    $('.praiseBtn').hover(function () {
        $('.icon-grey-praise').addClass('hide');
        if (praise == 0) {
            $('.icon-active-praise').removeClass('hide');
        } else {
            $('.icon-success-praise').removeClass('hide');
        }
    }, function () {
        if (!isPraise) {
            if (praise == 0) {
                $('.icon-grey-praise').removeClass('hide');
            } else {
                $('.icon-success-praise').removeClass('hide');
            }
            $('.icon-active-praise').addClass('hide');
        }
    });
</script>
{/block}